 
#include<iostream>
using namespace std;

int S[202], top;
int Q;

int main() {
    for (int i = 1; i <= 100; ++i) {
        S[++top] = 0;
    }
    
    cin >> Q;
    while (Q--) {
        int a, x;
        cin >> a;
        if (a == 1) {
            cin >> x;
            S[++top] = x;
        } else {
            cout << S[top--] << endl;
        }
    }
    return 0;
}
 